<template>
  <div class="rb-header">
    <div class="rb-logo-container">
      <img src="@/assets/images/logo.png" class="rb-logo" />
      润邦鞋业分拣系统
    </div>
    <div class="rb-tab-container">
      <rb-tab
        v-for="(item, index) in list"
        :key="item.path"
        :isActive="current === index"
        @click="changCurrent(item.path)"
        >{{ item.name }}</rb-tab
      >
      <rb-button
        v-show="showChangeBtn"
        class="rb-header-change-btn"
        type="green"
      >
        一键换班
      </rb-button>
    </div>
  </div>
</template>

<script setup>
const router = useRouter();
const route = useRoute();
const current = ref(0);
const list = [
  {
    path: "/order",
    name: "生产指令单",
  },
  {
    path: "/count",
    name: "计数台显示",
  },
  {
    path: "/process",
    name: "生产进度",
  },
];
const showChangeBtn = computed(() => {
  return route.meta.showChangeBtn;
});
watch(
  () => router.currentRoute.value,
  (newVal, oldVal) => {
    current.value = list.findIndex((item) => item.path == newVal.path);
  },
  {
    immediate: true,
  }
);

//改变当前页签
function changCurrent(value) {
  router.push(value);
}
</script>

<style lang='scss' scoped>
.rb-header {
  display: flex;
  width: 100vw;
  height: 140px;
  background: url("@/assets/images/header.png") center / cover no-repeat;
  .rb-logo-container {
    padding-left: 33px;
    width: 530px;
    font-size: 44px;
    font-weight: bold;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 18px;
    .rb-logo {
      width: 58px;
      height: 58px;
    }
  }
  .rb-tab-container {
    flex: 1;
    padding: 0 30px;
    display: flex;
    gap: 30px;
    align-items: center;
  }
  .rb-header-change-btn {
    width: 224px;
    height: 86px;
    font-size: 32px;
    box-shadow: var(--box-shadow);
  }
}
</style>